function Calendar(a, b, c, d, e, f) {
    this.beginYear = a || 2000;
    this.endYear = b || 2020;
    this.language = c || 1;
    this.patternDelimiter = d || "-";
    this.date2StringPattern = e || Calendar.language["date2StringPattern"][this.language].replace(/\-/g, this.patternDelimiter);
    this.string2DatePattern = f || Calendar.language["string2DatePattern"][this.language];
    this.dateControl = null;
    this.panel = this.getElementById("__calendarPanel");
    this.iframe = window.frames["__calendarIframe"];
    this.form = null;
    this.date = new Date();
    this.year = this.date.getFullYear();
    this.month = this.date.getMonth();
    this.colors = {
        "bg_cur_day": "#00CC33",
        "bg_over": "#EFEFEF",
        "bg_out": "#FFCC00"
    }
};
Calendar.language = {
    "year": ["\u5e74", "", "", "\u5e74"],
    "months": [["\u4e00\u6708", "\u4e8c\u6708", "\u4e09\u6708", "\u56db\u6708", "\u4e94\u6708", "\u516d\u6708", "\u4e03\u6708", "\u516b\u6708", "\u4e5d\u6708", "\u5341\u6708", "\u5341\u4e00\u6708", "\u5341\u4e8c\u6708"], ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"], ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"], ["\u4e00\u6708", "\u4e8c\u6708", "\u4e09\u6708", "\u56db\u6708", "\u4e94\u6708", "\u516d\u6708", "\u4e03\u6708", "\u516b\u6708", "\u4e5d\u6708", "\u5341\u6708", "\u5341\u4e00\u6708", "\u5341\u4e8c\u6708"]],
    "weeks": [["\u65e5", "\u4e00", "\u4e8c", "\u4e09", "\u56db", "\u4e94", "\u516d"], ["Sun", "Mon", "Tur", "Wed", "Thu", "Fri", "Sat"], ["Sun", "Mon", "Tur", "Wed", "Thu", "Fri", "Sat"], ["\u65e5", "\u4e00", "\u4e8c", "\u4e09", "\u56db", "\u4e94", "\u516d"]],
    "clear": ["\u6e05\u7a7a", "Clear", "Clear", "\u6e05\u7a7a"],
    "today": ["\u4eca\u5929", "Today", "Today", "\u4eca\u5929"],
    "close": ["\u5173\u95ed", "Close", "Close", "\u95dc\u9589"],
    "date2StringPattern": ["yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd"],
    "string2DatePattern": ["ymd", "ymd", "ymd", "ymd"]
};
Calendar.prototype.draw = function() {
    calendar = this;
    var b = [];
    b[b.length] = '<form id="__calendarForm" name="__calendarForm" method="post">';
    b[b.length] = '<table id="__calendarTable" width="100%" border="0" cellpadding="3" cellspacing="1" align="center">';
    b[b.length] = ' <tr>';
    b[b.length] = '  <th><input class="l" name="goPrevMonthButton" type="button" id="goPrevMonthButton" value="<" \/><\/th>';
    b[b.length] = '  <th colspan="5"><select class="year" name="yearSelect" id="yearSelect"><\/select><select class="month" name="monthSelect" id="monthSelect"><\/select><\/th>';
    b[b.length] = '  <th><input class="r" name="goNextMonthButton" type="button" id="goNextMonthButton" value=">" \/><\/th>';
    b[b.length] = ' <\/tr>';
    b[b.length] = ' <tr>';
    for (var i = 0; i < 7; i++) {
        b[b.length] = '<th class="theader">';
        b[b.length] = Calendar.language["weeks"][this.language][i];
        b[b.length] = '<\/th>'
    }
    b[b.length] = '<\/tr>';
    for (var i = 0; i < 6; i++) {
        b[b.length] = '<tr align="center">';
        for (var j = 0; j < 7; j++) {
            switch (j) {
            case 0:
                b[b.length] = '<td class="sun"> <\/td>';
                break;
            case 6:
                b[b.length] = '<td class="sat"> <\/td>';
                break;
            default:
                b[b.length] = '<td class="normal"> <\/td>';
                break
            }
        }
        b[b.length] = '<\/tr>'
    }
    b[b.length] = ' <tr>';
    b[b.length] = '  <th colspan="2"><input type="button" class="b" name="clearButton" id="clearButton" \/><\/th>';
    b[b.length] = '  <th colspan="3"><input type="button" class="b" name="selectTodayButton" id="selectTodayButton" \/><\/th>';
    b[b.length] = '  <th colspan="2"><input type="button" class="b" name="closeButton" id="closeButton" \/><\/th>';
    b[b.length] = ' <\/tr>';
    b[b.length] = '<\/table>';
    b[b.length] = '<\/form>';
    this.iframe.document.body.innerHTML = b.join("");
    this.form = this.iframe.document.forms["__calendarForm"];
    this.form.clearButton.value = Calendar.language["clear"][this.language];
    this.form.selectTodayButton.value = Calendar.language["today"][this.language];
    this.form.closeButton.value = Calendar.language["close"][this.language];
    this.form.goPrevMonthButton.onclick = function() {
        calendar.goPrevMonth(this)
    };
    this.form.goNextMonthButton.onclick = function() {
        calendar.goNextMonth(this)
    };
    this.form.yearSelect.onchange = function() {
        calendar.update(this)
    };
    this.form.monthSelect.onchange = function() {
        calendar.update(this)
    };
    this.form.clearButton.onclick = function() {
        calendar.dateControl.value = "";
        calendar.hide()
    };
    this.form.closeButton.onclick = function() {
        calendar.hide()
    };
    this.form.selectTodayButton.onclick = function() {
        var a = new Date();
        calendar.date = a;
        calendar.year = a.getFullYear();
        calendar.month = a.getMonth();
        calendar.dateControl.value = a.format(calendar.date2StringPattern);
        calendar.hide()
    };
    var i = 0
};
Calendar.prototype.bindYear = function() {
    var a = this.form.yearSelect;
    a.length = 0;
    for (var i = this.beginYear; i <= this.endYear; i++) {
        a.options[a.length] = new Option(i + Calendar.language["year"][this.language], i)
    }
};
Calendar.prototype.bindMonth = function() {
    var a = this.form.monthSelect;
    a.length = 0;
    for (var i = 0; i < 12; i++) {
        a.options[a.length] = new Option(Calendar.language["months"][this.language][i], i)
    }
};
Calendar.prototype.goPrevMonth = function(e) {
    if (this.year == this.beginYear && this.month == 0) {
        return
    }
    this.month--;
    if (this.month == -1) {
        this.year--;
        this.month = 11
    }
    this.date = new Date(this.year, this.month, 1);
    this.changeSelect();
    this.bindData()
};
Calendar.prototype.goNextMonth = function(e) {
    if (this.year == this.endYear && this.month == 11) {
        return
    }
    this.month++;
    if (this.month == 12) {
        this.year++;
        this.month = 0
    }
    this.date = new Date(this.year, this.month, 1);
    this.changeSelect();
    this.bindData()
};
Calendar.prototype.changeSelect = function() {
    var a = this.form.yearSelect;
    var b = this.form.monthSelect;
    for (var i = 0; i < a.length; i++) {
        if (a.options[i].value == this.date.getFullYear()) {
            a[i].selected = true;
            break
        }
    }
    for (var i = 0; i < b.length; i++) {
        if (b.options[i].value == this.date.getMonth()) {
            b[i].selected = true;
            break
        }
    }
};
Calendar.prototype.update = function(e) {
    this.year = e.form.yearSelect.options[e.form.yearSelect.selectedIndex].value;
    this.month = e.form.monthSelect.options[e.form.monthSelect.selectedIndex].value;
    this.date = new Date(this.year, this.month, 1);
    this.changeSelect();
    this.bindData()
};
Calendar.prototype.bindData = function() {
    var a = this;
    var b = this.getMonthViewDateArray(this.date.getFullYear(), this.date.getMonth());
    var c = this.getElementsByTagName("td", this.getElementById("__calendarTable", this.iframe.document));
    for (var i = 0; i < c.length; i++) {
        c[i].style.backgroundColor = a.colors["bg_over"];
        c[i].onclick = null;
        c[i].onmouseover = null;
        c[i].onmouseout = null;
        c[i].innerHTML = b[i] || " ";
        if (i > b.length - 1) continue;
        if (b[i]) {
            c[i].onclick = function() {
                if (a.dateControl) {
                    a.dateControl.value = new Date(a.date.getFullYear(), a.date.getMonth(), this.innerHTML).format(a.date2StringPattern)
                }
                a.hide()
            };
            c[i].onmouseover = function() {
                this.style.backgroundColor = a.colors["bg_out"]
            };
            c[i].onmouseout = function() {
                this.style.backgroundColor = a.colors["bg_over"]
            };
            var d = new Date();
            if (d.getFullYear() == a.date.getFullYear()) {
                if (d.getMonth() == a.date.getMonth()) {
                    if (d.getDate() == b[i]) {
                        c[i].style.backgroundColor = a.colors["bg_cur_day"];
                        c[i].onmouseover = function() {
                            this.style.backgroundColor = a.colors["bg_out"]
                        };
                        c[i].onmouseout = function() {
                            this.style.backgroundColor = a.colors["bg_cur_day"]
                        }
                    }
                }
            }
        }
    }
};
Calendar.prototype.getMonthViewDateArray = function(y, m) {
    var a = new Array(42);
    var b = new Date(y, m, 1).getDay();
    var c = new Date(y, m + 1, 0).getDate();
    for (var i = 0; i < c; i++) {
        a[i + b] = i + 1
    }
    return a
};
Calendar.prototype.show = function(a, b) {
    if (this.panel.style.visibility == "visible") {
        this.panel.style.visibility = "hidden"
    }
    if (!a) {
        throw new Error("arguments[0] is necessary!")
    }
    this.dateControl = a;
    b = b || a;
    this.draw();
    this.bindYear();
    this.bindMonth();
    if (a.value.length > 0) {
        this.date = new Date(a.value.toDate(this.patternDelimiter, this.string2DatePattern));
        this.year = this.date.getFullYear();
        this.month = this.date.getMonth()
    }
    this.changeSelect();
    this.bindData();
    var c = this.getAbsPoint(b);
    this.panel.style.left = c.x + "px";
    this.panel.style.top = (c.y + a.offsetHeight) + "px";
    this.panel.style.visibility = "visible"
};
Calendar.prototype.hide = function() {
    this.panel.style.visibility = "hidden"
};
Calendar.prototype.getElementById = function(a, b) {
    b = b || document;
    return document.getElementById ? b.getElementById(a) : document.all(a)
};
Calendar.prototype.getElementsByTagName = function(a, b) {
    b = b || document;
    return document.getElementsByTagName ? b.getElementsByTagName(a) : document.all.tags(a)
};
Calendar.prototype.getAbsPoint = function(e) {
    var x = e.offsetLeft;
    var y = e.offsetTop;
    while (e = e.offsetParent) {
        x += e.offsetLeft;
        y += e.offsetTop
    }
    return {
        "x": x,
        "y": y
    }
};
Date.prototype.format = function(a) {
    var o = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "w+": "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this.getDay()),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S": this.getMilliseconds()
    };
    if (/(y+)/.test(a)) {
        a = a.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(a)) {
            a = a.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length))
        }
    }
    return a
};
String.prototype.toDate = function(b, c) {
    b = b || "-";
    c = c || "ymd";
    var a = this.split(b);
    var y = parseInt(a[c.indexOf("y")], 10);
    if (y.toString().length <= 2) y += 2000;
    if (isNaN(y)) y = new Date().getFullYear();
    var m = parseInt(a[c.indexOf("m")], 10) - 1;
    var d = parseInt(a[c.indexOf("d")], 10);
    if (isNaN(d)) d = 1;
    return new Date(y, m, d)
};
document.writeln('<div id="__calendarPanel" style="position:absolute;visibility:hidden;z-index:9999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;">');
document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
var __ci = window.frames['__calendarIframe'];
__ci.document.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');
__ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
__ci.document.writeln('<head>');
__ci.document.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
__ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
__ci.document.writeln('<style type="text\/css">');
__ci.document.writeln('<!--');
__ci.document.writeln('body {font-size:12px;margin:0px;text-align:center;}');
__ci.document.writeln('form {margin:0px;}');
__ci.document.writeln('select {font-size:12px;background-color:#EFEFEF;}');
__ci.document.writeln('table {border:0px solid #CCCCCC;background-color:#FFFFFF}');
__ci.document.writeln('th {font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
__ci.document.writeln('th.theader {font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
__ci.document.writeln('select.year {width:64px;}');
__ci.document.writeln('select.month {width:60px;}');
__ci.document.writeln('td {font-size:12px;text-align:center;}');
__ci.document.writeln('td.sat {color:#0000FF;background-color:#EFEFEF;}');
__ci.document.writeln('td.sun {color:#FF0000;background-color:#EFEFEF;}');
__ci.document.writeln('td.normal {background-color:#EFEFEF;}');
__ci.document.writeln('input.l {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
__ci.document.writeln('input.r {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
__ci.document.writeln('input.b {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
__ci.document.writeln('-->');
__ci.document.writeln('<\/style>');
__ci.document.writeln('<\/head>');
__ci.document.writeln('<body>');
__ci.document.writeln('<\/body>');
__ci.document.writeln('<\/html>');
__ci.document.close();
document.writeln('<\/div>');
var calendar = new Calendar();